package negocio;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;


import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;

import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

@Entity
@Table(name="remitos")
public class Remito implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	@Id
	@Column(name="id_remito", nullable=false)
	private int id_remito;
	
	
	
	
	
	@OneToMany(cascade=CascadeType.MERGE)
	@JoinColumn(name="id_remito", referencedColumnName="id_remito")
	private List<ItemRemito>items = new ArrayList<>(); 
	
	@OneToOne(cascade=CascadeType.MERGE)
	@JoinColumn(name="id_orden_de_compra" , referencedColumnName="id_orden_de_compra")
	private OrdenCompra ordenCompra;



	public int getId_remito() {
		return id_remito;
	}

	public void setId_remito(int id_remito) {
		this.id_remito = id_remito;
	}


	public List<ItemRemito> getItems() {
		return items;
	}

	public void setItems(ArrayList<ItemRemito> items) {
		this.items = items;
	}

	@Override
	public String toString() {
		return "Remito [id_remito=" + id_remito + ", items=" + items + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + id_remito;
		result = prime * result + ((items == null) ? 0 : items.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Remito other = (Remito) obj;
		if (id_remito != other.id_remito)
			return false;
		if (items == null) {
			if (other.items != null)
				return false;
		} else if (!items.equals(other.items))
			return false;
		return true;
	}

	public OrdenCompra getOrdenCompra() {
		return ordenCompra;
	}

	public void setOrdenCompra(OrdenCompra ordenCompra) {
		this.ordenCompra = ordenCompra;
	}



	
	
	
	
	
	
	
	
	
	

}
